﻿using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;

[CreateAssetMenu(fileName = "Effect01-在几回合生成几点资源", menuName = "Skill/Effect/Effect01-在几回合生成几点资源", order = 1)]
public class Effect01 : EffectBase
{
    public int resourcesCount;
    public int turnCount;

    private Dictionary<Pair, int> RecordingChessDic = new();
    public override void Apply(Pair pair, GameEvent e, List<Chess> targets)
    {
        RecordingChessDic.TryAdd(pair,turnCount);
        RecordingChessDic[pair]--;
        if (RecordingChessDic[pair] == 0)
        {
            PlayerResourcesManager.GetInstance().AddResources(pair.Chess.GetChessSide(), resourcesCount);
            Debug.Log(pair.Chess.chessDate.chessName + "资源"+ resourcesCount);
            RecordingChessDic[pair] = turnCount;
        }
    }

    public override void RemoveDictionary(Pair pair)
    {
        RecordingChessDic.Remove(pair);
    }

    private void OnDisable()
    {
        RecordingChessDic.Clear();
    }
}
